const SetCookie = (name, value, expiry = 1000 * 60 * 60 * 24) => {
    let cookieString = `${encodeURIComponent(name)}=${encodeURIComponent(
        value
    )}`;
    if (expiry) {
        const date = new Date();
        date.setTime(date.getTime() + expiry);
        cookieString += `; expires=${date.toUTCString()}`;
    }
    cookieString += "; path=/";
    if (location.protocol === "https:") {
        cookieString += "; Secure";
    }
    cookieString += "; SameSite=Lax";
    document.cookie = cookieString;
};
const GetCookie = (name) => {
    const cookies = document.cookie.split("; ");
    for (let i = 0; i < cookies.length; i++) {
        const cookie = cookies[i].split("=");
        if (cookie[0] === name) {
            return decodeURIComponent(cookie[1]);
        }
    }
    return null;
};
const ClearCookie = (name) => {
    document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`;
};

export { SetCookie, GetCookie, ClearCookie };
